class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n=nums.size();
        int left=-1;//结果指针
        int right=n;
        int i=0;//扫描指针
        while(i<n)
        {
            //扫描到非0就给left指针
            if(nums[i]!=0)swap(nums[i++],nums[++left]);
            else i++;
        }
    }
};